import React, { useState } from 'react';
import { Button } from 'antd';
import { connect } from 'umi';
import HistoryTabCard from '@/components/HistoryTabCard';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
import { StartTaskModal } from '../../components';
import PendingAcceptance from './components/PendingAcceptance';
import Accepted from './components/Accepted';
/**
 * 我验收的 功能页面
 */
const MyAcceptance = ({ global }) => {
    // console.log('PendingAcceptance -> global', global);
    const { taskCount } = global;
    const { toAcceptTaskNum } = taskCount;
    // 发起任务弹窗显示与否
    const [startModalVisible, setStartModalVisible] = useState(false);
    const tabList = [
        {
            key: 'tab1',
            tab: `待验收(${toAcceptTaskNum})`
        },
        {
            key: 'tab2',
            tab: '已验收'
        }
    ];
    const extraButtons = (
        <Button
            type="primary"
            style={{ margin: '12px 0' }}
            onClick={() => {
                setStartModalVisible(true);
            }}
        >
            发起任务
        </Button>
    );
    return (
        <PageHeaderWrapper>
            <HistoryTabCard bordered={false} tabList={tabList} tabBarExtraContent={extraButtons}>
                <PendingAcceptance />
                <Accepted />
            </HistoryTabCard>
            <StartTaskModal visible={startModalVisible} setVisible={setStartModalVisible} />
        </PageHeaderWrapper>
    );
};

export default connect(({ global }) => ({
    global
}))(MyAcceptance);
